﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace growatt.Message.Util
{
    public static class ConvertHelper
    {
        /// <summary>
        /// 字节数组转16进制字符串
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string ByteToHexStr(byte[] bytes, int startindex = 0, int length = -1, string joinString = "")
        {
            string returnStr = "";
            if (bytes != null)
            {
                if (length == -1) length = bytes.Length;
                for (int i = startindex; i < startindex + length; i++)
                {
                    returnStr += bytes[i].ToString("X2") + joinString;
                }
            }
            return returnStr;
        }
    }
}
